<template>
  <div>
    <xw-pagenav :showAdd="false" />
    <el-row :gutter="12">
      <el-col :span="8">
        <el-card shadow="hover"> 站内信息 </el-card>
      </el-col>
      <el-col :span="8">
        <el-card shadow="hover"> 最新上架 </el-card>
      </el-col>
      <el-col :span="8">
        <el-card shadow="hover"> 热门电影 </el-card>
      </el-col>
    </el-row>
    <el-row :gutter="12">
      <el-col :span="12">
        <el-card shadow="hover">
          <div slot="header" class="clearfix">
            <span>折线图</span>
          </div>
          <div style="width: 100%; height: 300px" ref="line"></div>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card shadow="hover">
          <div slot="header" class="clearfix">
            <span>柱状图</span>
          </div>
          <div style="width: 100%; height: 300px" ref="bar"></div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
// import * as echarts from 'echarts'

export default {
  mounted() {
    this.lineFn()
    this.barFn()
  },
  methods: {
    lineFn() {
      var myChart = this.$echarts.init(this.$refs.line)
      myChart.setOption({
        tooltip: {
          trigger: 'axis',
          valueFormatter: value => '自定义 - ' + value
        },
        xAxis: {
          type: 'category',
          // 让x轴的坐标顶格
          boundaryGap: false,
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
          type: 'value'
        },
        // 坐标系
        series: [
          {
            data: [820, 932, 901, 934, 1290, 1330, 1320],
            type: 'line',
            // 线平滑
            smooth: true,
            lineStyle: {
              width: 0
            },
            showSymbol: false,
            // 阴影
            areaStyle: {}
          }
        ]
      })
    },
    barFn() {
      var myChart = this.$echarts.init(this.$refs.bar)
      myChart.setOption({
        tooltip: {
          trigger: 'axis',
          valueFormatter: value => '自定义 - ' + value
        },
        xAxis: {
          type: 'category',
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: [120, 200, 150, 80, 70, 110, 130],
            type: 'bar',
            itemStyle: {
              color: '#a90000'
            }
          }
        ]
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.el-row {
  margin-bottom: 10px;
}
</style>
